#include "stdio.h"
#include "stdlib.h"

struct flight{
    int number;
    char *Destination;
    int Model;
    int date[3];
    int start_time[3];
    int end_time[3];
    int amount380;
    int amount320;
};

struct ticket{
    int number;
    char *name;
    int id;
    struct ticket *next;
};

struct flight information[10];

void add_flight(struct flight *a);
struct ticket * shia();

int main(){
    int a;
    struct ticket *head;
    head=shia();
    printf("1.增加航班\n2.查询航班：输入目的地，按起飞时间输出所有航班信息\n3.查询售票信息，输入航班号\n4.订票，输入航班号、乘客姓名和身份证号\n5.退票，先选择航班，然后在输入乘客姓名6.保存航班及其订票情况到文件airplane.txt\n");
    while (scanf("%d",&a)!=EOF) {
        switch (a) {
           
        }
    }
}

void add_flight(struct flight *a){
    for (int i=0; i<10; i++) {
        if ((a+i)->number!=0) {
            scanf("%d %s %d %d %d %d %d %d %d %d %d %d %d %d\n",&((a+i)->number),(a+i)->Destination,&((a+i)->Model),&((a+i)->date[0]),&((a+i)->date[1]),&((a+i)->date[2]),&((a+i)->start_time[0]),&((a+i)->start_time[1]),&((a+i)->start_time[2]),&((a+i)->end_time[0]),&((a+i)->end_time[1]),&((a+i)->end_time[2]),&((a+i)->amount380),&((a+i)->amount320));
            break;
        }
    }
}

void find_flight(struct flight *b){
    int j=0;
    char aim[10];
    scanf("%s",aim);
    struct flight sort[10];
    for (int i=0; i<10; i++) {
        if (aim==((b+i)->Destination)) {
            sort[j]=*(b+i);
            j++;
        }
        else{
            printf("no such flight\n");
        }
    }
    double min[j+1];
    for (int u=0; u<j+1; u++) {
        min[u]=sort[u].start_time[0]*60+sort[u].start_time[1]+sort[u].start_time[2]/60;
    }
    for (int t=0; t<j; t++) {
        for (int e=0; e<j-t; e++) {
            if (min[e]>min[e+1]) {
                double temp;
                temp=min[e];
                min[e]=min[e+1];
                min[e+1]=temp;
                struct flight t;
                t=sort[e];
                sort[e]=sort[e+1];
                sort[e+1]=t;
            }
        }
    }
    for (int b=0; b<j+1; b++) {
        printf("%d %s %d %d %d %d %d %d %d %d %d %d\n",sort[b].number,sort[b].Destination,sort[b].Model,sort[b].date[0],sort[b].date[1],sort[b].date[2],sort[b].start_time[0],sort[b].start_time[1],sort[b].start_time[2],sort[b].end_time[0],sort[b].end_time[1],sort[b].end_time[2]);
    }
}

struct ticket * shia(){
    struct ticket *head = NULL,*pf = NULL,*pb;
    for (int i=0; i<1; i++) {
        p
        if (i==0) {
            pf=head=pb;
        }
        else{
            pf->next=pb;
        }
        pb->next=NULL;
        pf=pb;
    }
    return head;
}

void find_ticket(struct ticket *d){
    int number;
    scanf("%d",&number);
    while (d!=NULL) {
        if (number==d->number) {
            printf("%s %d",d->name,d->id);
        }
        d=d->next;
    }
}

if ((information+i)->Model==380) {
    (information+i)->amount380+=1;
}
else{
    (information+i)->amount320+=1;
}


void add_ticket(struct ticket *f){
    struct ticket *p=f,*pb;
    pb=(struct ticket*)malloc(sizeof(struct ticket));
    scanf("%d %s %d",&(pb->number),pb->name,&(pb->id));
    for (int i=0; i<10; i++) {
        if (pb->number==(information+i)->number) {
            if ((information+i)->Model==380) {
                if ((information+i)->amount380<5) {
                    while (p->next!=NULL) {
                        p=p->next;
                    }
                    p->next=pb;
                    pb->next=NULL;
                }
                else{
                    printf("航班已满");
                }
            }
            else{
                if ((information+i)->amount320<3) {
                    while (p->next!=NULL) {
                        p=p->next;
                    }
                    p->next=pb;
                    pb->next=NULL;
                }
                else{
                    printf("航班已满");
                }

            }
        }
    }
}